using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace MyXnaGame
{
    public abstract class HudComponent
    {
        protected SpriteFont hudFont;
        
        // NOTE: hud positions are hard-coded for screen-size of 1280x720
        // ... previously hard-coded values were for smaller size of 853x480
        // ... but you may set dynamically based on safe area dimensions
        protected Vector2 position = new Vector2(20, 20);
        const int DefaultLeftX = 150; //100;
        const int DefaultCenterX = 575; // 350;
        const int DefaultRightX = 925; // 550;
        //
        const int DefaultTopY = 75; // 50;
        const int DefaultMiddleY = 100;// 75;
        const int DefaultBottomY = 125; // 100;

        public enum PresetPosition
        {
            TopLeft,
            MiddleLeft,
            BottomLeft,
            TopCenter,
            MiddleCenter,
            BottomCenter,
            TopRight,
            MiddleRight,
            BottomRight,
        }

        public HudComponent()
        {
        }

        protected void SetPosition(PresetPosition presetPosition)
        {
            switch (presetPosition)
            {
                case (PresetPosition.TopLeft): { position = new Vector2(DefaultLeftX, DefaultTopY); } break;
                case (PresetPosition.MiddleLeft): { position = new Vector2(DefaultLeftX, DefaultMiddleY); } break;
                case (PresetPosition.BottomLeft): { position = new Vector2(DefaultLeftX, DefaultBottomY); } break;
                    //
                case (PresetPosition.TopCenter): { position = new Vector2(DefaultCenterX, DefaultTopY); } break;
                case (PresetPosition.MiddleCenter): { position = new Vector2(DefaultCenterX, DefaultMiddleY); } break;
                case (PresetPosition.BottomCenter): { position = new Vector2(DefaultCenterX, DefaultBottomY); } break;
                    //
                case (PresetPosition.TopRight): { position = new Vector2(DefaultRightX, DefaultTopY); } break;
                case (PresetPosition.MiddleRight): { position = new Vector2(DefaultRightX, DefaultMiddleY); } break;
                case (PresetPosition.BottomRight): { position = new Vector2(DefaultRightX, DefaultBottomY); } break;
                default: { } break;
            }
        }

        //public HudComponent(int x, int y)
        //{
        //    position.X = x;
        //    position.Y = y;
        //}

        public virtual void Draw(SpriteBatch spriteBatch)
        {
        }

        internal void SetFont(SpriteFont hudFont)
        {
            this.hudFont = hudFont;
        }
    }
}
